package com.chinairi.mall.controller;


import com.chinairi.common.utils.ResponseUtil;
import com.chinairi.mall.controller.viewobject.ServiceTypeTreeVO;
import com.chinairi.mall.model.ServiceType;
import com.chinairi.mall.service.IServiceTypeService;
import com.chinairi.mall.service.modelobject.ServiceTypeMO;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import com.chinairi.common.controller.BaseController;

import java.io.IOException;
import java.util.List;

/**
 * <p>
 * 服务类型 前端控制器
 * </p>
 *
 * @author gsl
 * @since 2020-09-03
 */
@RestController
@RequestMapping("/service-type")
public class ServiceTypeController extends BaseController {

    @Autowired
    private IServiceTypeService iServiceTypeService;

    /**
     * 首页服务大类查询
     * @param serviceTypeName
     * @throws IOException
     */
    @GetMapping("/get")
    public void get(String serviceTypeName) throws IOException {
        List<ServiceType> serviceTypeList = iServiceTypeService.getList(serviceTypeName);
        ResponseUtil.showMessage("success","查询成功",serviceTypeList);
    }

    /**
     * 根据stSerTypeDbid查找子类
     * @param stSerTypeDbid 合同中服务的编号
     * @throws IOException 异常
     */
    @GetMapping("/getListByStSerTypeDbId")
    public void getListByStSerTypeDbId(String stSerTypeDbid) throws IOException {
        List<ServiceTypeMO> list = iServiceTypeService.getListByStSerTypeDbId(stSerTypeDbid);
        ResponseUtil.showMessage("success","查询成功",list);
    }

    /**
     * 获取服务类型树
     * @throws IOException
     */
    @GetMapping("/getServiceTree")
    public void getServiceTree() throws IOException {
        ServiceTypeTreeVO serviceTypeTreeVo = iServiceTypeService.getServiceTree();
        ResponseUtil.showMessage("success","查询成功", serviceTypeTreeVo);
    }
}
